package com.luoxiang.socialandroid.adapter;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.luoxiang.socialandroid.R;
import com.luoxiang.socialandroid.bean.CreditLog;
import com.luoxiang.socialandroid.bean.Dynamic;
import com.luoxiang.socialandroid.bean.RechargeLog;
import com.luoxiang.socialandroid.bean.RechargeRecordBean;

import java.util.ArrayList;
import java.util.List;

/**
 * @Description TODO
 * @systemUser Administrator
 * @Author LX
 * @Date 09-23-2022 周五 13:30
 */
public class RechargeRecordAdapter extends RecyclerView.Adapter<RechargeRecordAdapter.ViewHolder> {
    private List<RechargeLog> list = new ArrayList<>();
    public void setData(List<RechargeLog> list){
        this.list = list;
    }


    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext())
                .inflate(R.layout.item_rechargerecord, parent, false);
        RechargeRecordAdapter.ViewHolder holder = new RechargeRecordAdapter.ViewHolder(view);
        return holder;
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
        holder.enter_number.setText(list.get(position).getDesc());
        holder.tv_date.setText(list.get(position).getCreateTime());
        holder.add_ppbi.setText("+" + list.get(position).getCoin() + "PP");
        int payWay = list.get(position).getPayWay();
        if (payWay == 0) {
            //微信支付
            holder.img_paymodel.setImageResource(R.mipmap.ic_weixinaaa);
        } else {
            holder.img_paymodel.setImageResource(R.mipmap.ic_zhifubaoaa);
        }
    }

    @Override
    public int getItemCount() {
        if (list!=null){
            return list.size();

        }else {
            return 0;
        }
    }

    public class ViewHolder extends RecyclerView.ViewHolder {
        ImageView img_paymodel;
        TextView enter_number, tv_date, add_ppbi;

        public ViewHolder(@NonNull View itemView) {
            super(itemView);
            img_paymodel = itemView.findViewById(R.id.img_paymodel);
            enter_number = itemView.findViewById(R.id.enter_number);
            tv_date = itemView.findViewById(R.id.tv_date);
            add_ppbi = itemView.findViewById(R.id.add_ppbi);
        }
    }
}
